<?php
/**
 * Created by PhpStorm.
 * User: wumengmeng <wu_mengmeng@foxmail.com>
 * Date: 2019/4/26 0026
 * Time: 14:35
 */

namespace HiCommon\Service;

use HiCommon\Repository\CheckpointMakeDateRepository;

class CheckpointMakeDateService extends BaseService
{

    /**
     * 累加已预约的数量
     *
     * @param int       $n_id               预定id
     * @param string    $n_order_time_type  类型 am pm
     * @param int       $n_order_num        本次预定量
     * @param int       $n_total_num        限定预定量
     *
     * @return array
     * @author wumengmeng <wu_mengmeng@foxmail.com>
     */
    public function api_increase_order_num($n_id,$n_order_time_type,$n_order_num = 1,$n_total_num = 0){

        $s_field = $n_order_time_type.'_order';
        $res = CheckpointMakeDateRepository::increase_num_limit($n_id,$s_field,$n_order_num,$n_total_num);
        if(!$res){
            return hello_error('预约失败');
        }
        return  hello_success('成功');
    }

    /**
     * 获取分页数据-条件门店id
     *
     * @param $arr_where
     *
     * @return array
     * @author wumengmeng <wu_mengmeng@foxmail.com>
     */
    public function api_effective_list_by_shopid($arr_where)
    {
        $arr_option = [
          'order'=>['key'=>'day','value'=>'asc'],
          'where'=>$arr_where
        ];
        $data = CheckpointMakeDateRepository::get_effective_list_common($arr_option)->toarray();
        $data = list_page_data_for_api($data);
        return  hello_success('成功',$data);

    }






}